package com.neusoft.resturant.controller;

import com.neusoft.resturant.common.utils.PageResult;
import com.neusoft.resturant.common.utils.R;
import com.neusoft.resturant.entity.ResDishes;
import com.neusoft.resturant.entity.ResShop;
import com.neusoft.resturant.service.IResDishesService;
import lombok.Builder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: resturant
 * @description:
 * @author: lydms
 * @create: 2023-11-18 20:16
 **/

@RestController
@RequestMapping("/admin/dishes")
public class ResdishesCotroller {

    @Autowired
    private IResDishesService resDishesService;

    /**
     * 分页查询
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/list2")
    public R list2(ResDishes resDishes,  Integer pageNum, Integer pageSize)
    {
        if(pageNum==null){
            pageNum=1;
        }
        if(pageSize==null){
            pageSize=8;

        }
        PageResult list2 = resDishesService.selectResDishList2(resDishes,pageNum,pageSize);
        return R.success(list2);
    }


    /**
     * 根据id查寻
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public R getbyId(@PathVariable Long id){

     ResDishes resDishes =  resDishesService.selectById(id);

    return R.success(resDishes);
    }

}
